<template>
  <div id="ForgetPwd">
    <nav-bar title="忘记密码"></nav-bar>
    <div id="steps">
      <van-steps :active="activeStep" active-icon="success" active-color="#38f">
        <van-step>身份验证</van-step>
        <van-step>设置新密码</van-step>
        <van-step>完成</van-step>
      </van-steps>
    </div>
    <transition :name="curPage" mode="out-in">
      <keep-alive>
        <router-view/>
      </keep-alive>
    </transition>
  </div>
</template>

<script>
import NavBar from '@/components/NavBar/NavBar';

export default {
  name: 'ForgetPwd',
  components: {
    NavBar
  },
  data () {
    return {
      show: true,
      curPage: 'slide-left',
      activeStep: 0
    }
  },
  watch: {
    $route (to, from) {
      console.log(to);
      if (to.path === '/forgetPwd/2') {
        this.curPage = 'slide-left'
        this.activeStep = 1
      } else {
        this.curPage = 'slide-right'
        this.activeStep = 0
      }
    }
  }
}
</script>

<style scoped>
.slide-right-enter-active,
.slide-right-leave-active,
.slide-left-enter-active,
.slide-left-leave-active {
  will-change: transform;
  transition: all .5s;
  position: absolute;
  width: 100%;
  left: 0;
}

.slide-right-enter {
  transform: translateX(-100%);
}

.slide-right-leave-active {
  transform: translateX(100%);
}

.slide-left-enter {
  transform: translateX(100%);
}

.slide-left-leave-active {
  transform: translateX(-100%);
}
</style>
